import request from '@/config/axios'

import { BaseModel } from '@/api/common/baseModel'

export interface Model extends BaseModel {
  clientId: string
  secret: string
  logo: string
  description: string
  accessTokenValiditySeconds: number
  refreshTokenValiditySeconds: number
  redirectUris: string[]
  autoApprove: boolean
  authorizedGrantTypes: string[]
  scopes: string[]
  authorities: string[]
  resourceIds: string[]
  additionalInformation: string
  isAdditionalInformationJson: boolean
  createTime: Date
}

// 查询 OAuth2 客户端的列表
export const getPage = (params: PageParam) => {
  return request.get({ url: import.meta.env.VITE_BASE_ROLE + '/userCenter/auth/oauth2/client/page.json', params })
}

// 查询 OAuth2 客户端的详情
export const getById = (id: string) => {
  return request.get({ url: import.meta.env.VITE_BASE_ROLE + '/userCenter/auth/oauth2/client/getById.json?id=' + id })
}

// 修改 OAuth2 客户端
export const update = (data: Model) => {
  return request.put({ url: import.meta.env.VITE_BASE_ROLE + '/userCenter/auth/oauth2/client/update.json', data })
}

// 删除 OAuth2
export const del = (id: string) => {
  return request.delete({ url: import.meta.env.VITE_BASE_ROLE + '/userCenter/auth/oauth2/client/del.json?id=' + id })
}
